package com.cdl.controller; 																

import javax.validation.Valid;

import org.slf4j.Logger;		
import org.slf4j.LoggerFactory;		
import org.springframework.beans.factory.annotation.Autowired;							  
import org.springframework.stereotype.Controller;										  
import org.springframework.validation.BindingResult;										  
import org.springframework.web.bind.annotation.RequestMapping;							  
import org.springframework.web.bind.annotation.ResponseBody;						      	  
import com.cdl.entity.SysPara;													  
import com.cdl.response.DataResponse;													  
import com.cdl.response.FormResponse;													  
import com.cdl.response.PageResponse;													  
import com.cdl.response.SimpleResponse;													  
import com.cdl.service.SysParaService;												  
import com.github.pagehelper.PageInfo;												  


@Controller 																				  
@RequestMapping("sysPara")															  
public class SysParaController extends BasicController{  														  
	   
	    private static Logger logger = LoggerFactory.getLogger(SysParaController.class);	  
		
		@Autowired																			  
		SysParaService sysParaServiceImpl ;															  
	 	
	 	/**  																				  
	 	 * 跳转到主页面  																			  
	 	 * @return  																		  
	 	 */  																				  
	 	@RequestMapping("/main")  														  
	 	public String  toMain(){  															  
	 		logger.info("跳转到主页面-->sys_para_main.jsp");  										  
	 		return "sys_para_main";  												      
	 	}	
	 																					  
 		/** 																				  
 	 	 * 跳转到查询页面 																		  
	     * @return 																			  
		 */ 																				  
		@RequestMapping("/query") 														  
		public String  toQuery(){ 															  
		 	logger.info("跳转到查询页面-->sys_para_query.jsp"); 									  
		 	return "sys_para_query"; 													  
		} 																					  
	    
	    /**   																				  
	     * 跳转到列表页面   																		  
	     * @return   																		  
      	 */   
	    @RequestMapping("/list")   														  
	    	public String  toList(){   														  
	    	logger.info("跳转到列表页面-->sys_para_list.jsp");   									  
	    	return "sys_para_list";   														  
		}
		   																				  
		/**   																				  
		 * 跳转到操作表单页面   																	  
		 * @return   																		  
		 */   																				  
		@RequestMapping("/form")   														  
		public String toForm(){   															  
			logger.info("跳转到操作表单页面-->sys_para_form.jsp");   								  
			return "sys_para_form";   														  
		}
				   																			  
    	/**   																				  
    	 * 跳转到明细页面   																		  
    	 * @param id   																		  
    	 * @return   																		  
    	 */   																				  
    	@RequestMapping("/detail")   														  
    	public String toDetail(String id){   												  
    		logger.info("跳转到明细页面-->sys_para_detail.jsp");  									  
    		return "sys_para_detail";   													  
    	}  
    	
    	 																				  
		/***		  																		  
		 * 查询列表		  																	  
		 * @param user		  																  
		 * @return		  																	  
		 */		  																		      
		@ResponseBody	  																	  
		@RequestMapping("/getList")	  													  
		public PageResponse<SysPara> getList(SysPara sysPara){  			  
			logger.info("获取数据列表--->"+sysPara.toString());  						  
			PageInfo<SysPara> page = sysParaServiceImpl.getPage(sysPara);  				  
			PageResponse<SysPara> response = new PageResponse<SysPara>() ;	  	  
			response.setData(page);  														  
			return response ;  																  
		}  	
		
																						  
		/**																					  
		 * 查询单条																			  
		 * @param sysPara															  
		 * @return																		      
		 */																					  
		@ResponseBody																		  
		@RequestMapping("/get")															  
		public DataResponse<SysPara> get(SysPara sysPara){				  
			logger.info("获取单条数据--->"+sysPara.toString());						  
			SysPara data = sysParaServiceImpl.get(sysPara);		                          
			DataResponse<SysPara> response = new DataResponse<SysPara>();	      
			response.setData(data);		                                                      
			return response ;		                                                          
		}	
		
																						  
		/*** 																	              
		 * 新增 																			      
		 * @param sysPara 															  
		 */  																				  
		@ResponseBody  																		  
		@RequestMapping("/add")  															  
		public FormResponse<String> add(@Valid SysPara sysPara,BindingResult result){  					  
			logger.info("新增数据-->"+sysPara.toString());  							  
			FormResponse<String> response = handleErrorResule(result);  		  			  
			if(response.isSuccess()){  														  
				sysParaServiceImpl.add(sysPara);  												  
				response.setMessage("新增成功！");  											  
			}else{ 																			  
				response.setMessage("新增失败！");  											  
			}  																				  
			return response;  															      
		}  
																							  
		/***  																				  
		 * 修改 																			      
		 * @param sysPara  															  
		 */  																				  
		@ResponseBody  																		  
		@RequestMapping("/update")  														  
		public FormResponse<Void> update(@Valid SysPara sysPara,BindingResult result){  					  
			logger.info("修改数据-->"+sysPara.toString());  							  
			FormResponse<Void> response = handleErrorResule(result);  						  
			if(response.isSuccess()){  														  
				sysParaServiceImpl.update(sysPara);  											  
				response.setMessage("修改成功！");  											  
			}else{  																		  
				response.setMessage("修改失败！");  											  
			}  																				  
			return response;  																  
		}  	
																						  
		/**  																				  
		 * 删除  																			      
		 * @param sysPara  															  
		 */  																				  
		@ResponseBody  																		  
		@RequestMapping("/del") 															  
		public SimpleResponse<Void> delete(SysPara sysPara){  					  
			logger.info("删除数据-->"+sysPara.toString());  							  
			SimpleResponse<Void> response = new SimpleResponse<Void>();  					  
			sysParaServiceImpl.delete(sysPara);  												  
			response.setSuccess(true);  													  
			return response;  																  
		}		 																			  
 
	 
	 
	 
	}  



